﻿using System;
namespace Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000 {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="atm1", Namespace="http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", Target=typeof(Atm1))]
    public class Atm1Serializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IAtm1 clazz;
        
        public Atm1Serializer(IAtm1 clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("slotid");
            if (clazz.Slotid!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Slotid))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Slotid");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("slotno");
            if (clazz.Slotno!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Slotno))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Slotno");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("slotmno");
            if (clazz.Slotmno!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Slotmno))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Slotmno");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("slotmnfd");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Slotmnfd))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("slotmnf");
            if (clazz.Slotmnf!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Slotmnf))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Slotmnf");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("evidslotown");
            if (clazz.Evidslotown!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Evidslotown))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Evidslotown");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("slotadc");
            if (clazz.Slotadc!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Slotadc))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Slotadc");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("slotadst");
            if (clazz.Slotadst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Slotadst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Slotadst");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("slotadhno");
            if (clazz.Slotadhno!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Slotadhno))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Slotadhno");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("usestarttime");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.Usestarttime))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("useendtime");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.Useendtime))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="slotid") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm1>slotid");
                }
                clazz.Slotid = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("slotid")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm1>slotid", Reader.LocalName);
            }
            if (Reader.LocalName=="slotno") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm1>slotno");
                }
                clazz.Slotno = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("slotno")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm1>slotno", Reader.LocalName);
            }
            if (Reader.LocalName=="slotmno") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm1>slotmno");
                }
                clazz.Slotmno = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("slotmno")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm1>slotmno", Reader.LocalName);
            }
            if (Reader.LocalName=="slotmnfd") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm1>slotmnfd");
                }
                clazz.Slotmnfd = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("slotmnfd")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm1>slotmnfd", Reader.LocalName);
            }
            if (Reader.LocalName=="slotmnf") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm1>slotmnf");
                }
                clazz.Slotmnf = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("slotmnf")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm1>slotmnf", Reader.LocalName);
            }
            if (Reader.LocalName=="evidslotown") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm1>evidslotown");
                }
                clazz.Evidslotown = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("evidslotown")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm1>evidslotown", Reader.LocalName);
            }
            if (Reader.LocalName=="slotadc") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm1>slotadc");
                }
                clazz.Slotadc = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("slotadc")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm1>slotadc", Reader.LocalName);
            }
            if (Reader.LocalName=="slotadst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm1>slotadst");
                }
                clazz.Slotadst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("slotadst")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm1>slotadst", Reader.LocalName);
            }
            if (Reader.LocalName=="slotadhno") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm1>slotadhno");
                }
                clazz.Slotadhno = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("slotadhno")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm1>slotadhno", Reader.LocalName);
            }
            if (Reader.LocalName=="usestarttime") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm1>usestarttime");
                }
                clazz.Usestarttime = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("usestarttime")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm1>usestarttime", Reader.LocalName);
            }
            if (Reader.LocalName=="useendtime") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm1>useendtime");
                }
                clazz.Useendtime = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("useendtime")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>atm1>useendtime", Reader.LocalName);
            }
        }
    }
}
